package com.zhilei.redissonConfig;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 志磊
 * redisson的配置类
 */
@Configuration
public class RedissonConfig {

    /**
     * 配置redisson
     *
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://localhost:6379")
                .setPassword("zhilei")
                .setDatabase(0)
                // 设置连接池大小
                .setConnectionPoolSize(20)
                // 连接池最小连接数
                .setConnectionMinimumIdleSize(20)
                // 设置超时时间
                .setConnectTimeout(60 * 1000);
        return Redisson.create(config);
    }
}
